#include "widget.h"
#include "settingsdialog.h"
#include"instructionwidget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    // 创建主界面和按钮
    maininterface=new QLabel;
    QPixmap p1=QPixmap("3.png");
    maininterface->setPixmap(p1);
    start = new QPushButton("开始", maininterface);
    instruct = new QPushButton("介绍",maininterface);
    setting = new QPushButton("设置", maininterface);

    title=new QLabel("猫  鼠  跑  酷",maininterface);


    title->setStyleSheet   ("background-color: transparent; border: none;font-family: 华文彩云; font-size: 40px; color: #F33333;");
    start->setStyleSheet   ("background-color: transparent; border: none;font-family: 华文琥珀; font-size: 24px; color: #F28034;");
    instruct->setStyleSheet("background-color: transparent; border: none;font-family: 华文琥珀; font-size: 24px; color: #F20004;");
    setting->setStyleSheet ("background-color: transparent; border: none;font-family: 华文琥珀; font-size: 24px; color: #00F2DC;");

    // 设置按钮大小和位置
    title->setFixedSize(250,50);
    start->setFixedSize(80, 30);
    instruct->setFixedSize(80, 30);
    setting->setFixedSize(80, 30);
    int x = p1.width(), y = p1.height();

    title->move(10,10);
    start->move((x-100), y * 0.25);
    instruct->move((x-100), y * 0.5);
    setting->move((x-100), y*0.75);

    // 连接设置按钮的点击信号到槽函数
    connect(setting, SIGNAL(clicked()),this,SLOT(showSettingsDialog()));
    connect(instruct,SIGNAL(clicked()),this,SLOT(gotoroleinstruction()));

    // 设置布局
    QVBoxLayout *mainbox = new QVBoxLayout;
    mainbox->addWidget(maininterface);
    this->setLayout(mainbox);
}
void Widget::gotoroleinstruction()
{
    // 创建并显示 InstructionWidget 对象
    instructionwidget *instructionWidget = new instructionwidget;
    instructionWidget->show();
}

// 槽函数，显示设置对话框
void Widget::showSettingsDialog()
{
    // 创建并显示设置对话框
    SettingsDialog *settingsDialog = new SettingsDialog(this);
    settingsDialog->exec(); // 使用 exec() 函数以模态方式显示对话框
}

Widget::~Widget() {}
